import numpy as np
import mpl_toolkits.mplot3d
import matplotlib.pyplot as plt


x=[ 583.622986, 1529.785034, 1397.54, 583.622986]
y=[ 992.049011, 995.510986, 737.25, 992.049011]
#z=[0,0,0]

ax=plt.subplot(111)
ax.plot(x, y, 'r');


x=[1397.54]
y=[737.25]
#z=[0]
ax.plot(x, y, 'bo');

XMicroPixelToMM = 0.001725
YMicroPixelToMM = 0.001725

PixelX = [ -424, -432 ]
PixelY = [ -592, -722 ]

x=[ 583.622986, 1529.785034, 1397.54, 583.622986]
y=[ 992.049011, 995.510986, 737.25, 992.049011]

Ax = x
Ay = y

Ax[0] = x[0] + PixelX[0] * (XMicroPixelToMM);
Ay[0] = y[0] + PixelY[0] * (YMicroPixelToMM);

Ax[1] = x[1] + PixelX[1] * (XMicroPixelToMM);
Ay[1] = y[1] + PixelY[1] * (YMicroPixelToMM);

Ax[2] = 1396.87;
Ay[2] = 738.463;

Ax[3] = x[0] + PixelX[0] * (XMicroPixelToMM);
Ay[3] = y[0] + PixelY[0] * (YMicroPixelToMM);

ax.plot(Ax, Ay, 'y');

#ax.set_zlabel('z')
ax.set_ylabel('y')
ax.set_xlabel('x')

plt.show()
